package com.project.mapper;

import com.project.bean.EmployeeBean;
import com.project.bean.ProgressBean;
import com.project.bean.ProjectBean;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.util.List;
@Mapper
public interface IProgressMapper {
    /**
     * 根据id修改项目完成日期
     * @param id id
     * @param completeDate 完成日期
     */
    @Update("update t_progress set pp_completeDate=#{completeDate} where fk_emId=#{id}")
    public void updateCompleteDate(@Param("id") int id, @Param("completeDate") String completeDate);

    /**
     * 为该项目添加员工
     * @param progressBean
     */
    @Insert("insert into t_progress(pp_partDate,pp_completeDate,fk_emId,fk_projectId)" +
            "values(#{partDate},#{completeDate},#{employeeBean.employeeId},#{projectBean.projectId})")
    public void addProgress(ProgressBean progressBean);

    /**
     * 根据项目id，修改项目状态
     * @param projectId 项目id
     * @param projectState 项目状态
     */
    @Update("update t_project set p_state=#{projectState} where pk_projectId=#{projectId}")
    public void updateState(@Param("projectId") int projectId,
                            @Param("projectState") String projectState);

    /**
     * 根据项目id修改员工完成日期
     * @param projectId 项目id
     * @param date 日期
     */
    @Update("update t_progress set pp_completeDate=#{date} where fk_projectId=#{projectId} and pp_completeDate='未完成' ")
    public void updateDate(@Param("projectId") int projectId,@Param("date") String date);
}
